<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath }"></c:set>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>用户登录</title>
<!-- Favicon icon -->
<link rel="icon" type="image/png"
	href="${path }/assets/images/favicon-32x32.png">
<!-- Base Styling  -->
<link rel="stylesheet" href="${path }/assets/main/css/fonts.css">
<link rel="stylesheet" href="${path }/assets/main/css/style.css">
</head>

<body>
	<div id="main-wrapper" class="show">

		<div class="container-fluid">
			<div class="row">
				<div class="col-xl-7 p-0 b-center bg-size">
					<img class="img-fluid" src="${path }/assets/images/bg-register.png"
						alt="tabib app">
				</div>
				<div class="col-xl-5 p-0">
					<div class="login-tabib">
						<div>
							<div class="text-center">
								<a class="logo"> <img class="img-fluid"
									src="${path }/assets/images/logo.png" alt="loogin page">
								</a>
							</div>
							<div class="login-main">
								<form class="theme-form" id="submitLogin"
									action="${path}/UserinfoController?action=login&old=${header.referer }"
									method="post">
									<h4>登录账号</h4>
									<style>
.regSuccess {
	text-align: center;
	margin-top: 30px;
	font-size: 10px;
	font-weight: 600;
	color: #DC143C;
}
</style>
									<c:if test="${param.mes=='success' }">
										<div class="regSuccess">
											<span>注册成功，请登录</span>
										</div>
									</c:if>
									<div class="regSuccess">
										<span id="errorMes"></span>
									</div>
									<div class="form-group m-b-10">
										<label class="col-form-label">账号</label> <input
											class="form-control" type="text" placeholder="账号"
											id="username" name="username">
									</div>
									<div class="form-group m-b-10">
										<label class="col-form-label">密码</label>
										<div class="form-input position-relative">
											<input class="form-control" type="password"
												placeholder="*********" id="userpass" name="password">
											<div class="show-hide">
												<span class="show"></span>
											</div>
										</div>
									</div>
									<div class="form-group mb-0">
										<div class="checkbox p-0">
											<input id="checkbox1" type="checkbox" name="remember">
											<label class="text-muted" for="checkbox1">自动登录 </label>
										</div>
										<a class="link text-primary" href="${path }/web/retrievePass.jsp" id="forget">忘记密码</a>
										<div class="mt-3">
											<button class="btn btn-primary w-100" type="button"
												id="loginButton">登录</button>
										</div>
									</div>
									<p class="mt-4 mb-0">
										没有账号?<a class="ms-2 text-primary text-center"
											href="${path }/web/userRegister.jsp">创建账户</a>
									</p>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>

	<!-- JQuery v3.5.1 -->
	<script src="assets/plugins/jquery/jquery.min.js"></script>

	<!-- popper js -->
	<script src="assets/plugins/popper/popper.min.js"></script>

	<!-- Bootstrap -->
	<script src="assets/plugins/bootstrap/js/bootstrap.js"></script>

	<!-- Moment -->
	<script src="assets/plugins/moment/moment.min.js"></script>

	<!-- Date Range Picker -->
	<script src="assets/plugins/daterangepicker/daterangepicker.min.js"></script>

	<!-- Main Custom JQuery -->
	<script src="assets/js/toggleFullScreen.js"></script>
	<script src="assets/js/main.js"></script>

</body>
<script src="${path}/js/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
	//ajax判断登录时账号和密码是否正确
	function checkByAjax() {
		var username = $("#username").val();
		var userpass = $("#userpass").val();
		var remember = $("#remember").val();
		$.ajax({
			url : "${path}/UserinfoController?action=toLogin",
			type : "post",
			data : {
				username : username,
				userpass : userpass,
				remember : remember
			},
			success : function(data) {
				if ("fail" == data) {
					$("#errorMes").css("color", "red");
					$("#errorMes").html("账号或密码错误，请重新输入！");
					return ;
				}
				else if("block"==data){
					alert("您因违反《国家航天局条例规定》已被系统拉黑！");
					return;
				}
				else{
					$("#submitLogin").submit();
				}
			}
		});
	}
	
	$(function() { 
		
		$("#loginButton").on("click", checkByAjax);
	
	});
</script>
</html>